import axios from 'axios';
import { Pagination, PaginationData } from '@/types/global';

export type AnnouncementParams = Pagination;

export interface AnnouncementVO {
  createOrgId: string; // 创建组织ID
  createOrgName: string; // 创建组织名称
  createTime: string;
  creator: string; // 创建人id
  creatorName: string; // 创建人名称
  deleteFlag: string; // 是否删除,1已删除,0正常
  id: string;
  showFlag: string;
  tenantId: string; // 租户ID
  text: string; // 公告正文
  title: string; // 公告标题
}
export interface CreateAnnouncementDTO {
  text: string; // 公告正文
  title: string; // 公告标题
}
export interface UpdateAnnouncementDTO extends CreateAnnouncementDTO {
  id: string;
}

export function getAnnouncementList(data: AnnouncementParams) {
  return axios.post<PaginationData<AnnouncementVO>>(
    'mdm/systemAnnouncement/selectSystemAnnouncementByPage',
    data
  );
}
export function createAnnouncement(data: CreateAnnouncementDTO) {
  return axios.post('mdm/systemAnnouncement/insertSystemAnnouncement', data);
}
export function updateAnnouncement(data: UpdateAnnouncementDTO) {
  return axios.post('mdm/systemAnnouncement/updateSystemAnnouncement', data);
}
export function deleteAnnouncement(id: string) {
  return axios.post(`mdm/systemAnnouncement/deleteSystemAnnouncement?id=${id}`);
}
export function showSystemAnnouncement(id: string) {
  return axios.post(`mdm/systemAnnouncement/showSystemAnnouncement?id=${id}`);
}
// 首页-不分页查询公告
export function selectSystemAnnouncement() {
  return axios.get<AnnouncementVO[]>(
    'mdm/systemAnnouncement/selectSystemAnnouncement'
  );
}
